<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:app="http://springfuse.jaxio.com/app"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/layouts/main.xhtml">
	<ui:define name="toolbarChildren">
		<p:toolbarGroup rendered="#{sub or readonly}">
			<p:commandButton id="back" action="#{bean.back()}" process="@none" ajax="false" immediate="true"
				value="#{msg.back}" icon="ui-icon-arrowreturnthick-1-w"/>
		</p:toolbarGroup>
		<p:toolbarGroup rendered="#{not sub and not readonly}">
			<p:commandButton id="close" oncomplete="askForSaveDialog.show(); APP.focusAskForSaveDialog();" 
				ajax="true" immediate="true" process="@this"
				icon="ui-icon-close"
				value="#{msg.menu_close}"
				title="#{msg.menu_close} #{title}"/>
			<p:commandButton id="delete" icon="ui-icon-trash"
				onclick="askForDeleteDialog.show(); APP.focusAskForDeleteDialog();"
				value="#{msg.menu_delete_and_close}"
				title="#{msg.menu_delete_and_close} #{title}"
				disabled="#{empty bean.entity.id}" />
			<p:separator />
		</p:toolbarGroup>
	</ui:define>
	<ui:define name="content">
		<p:breadCrumb model="#{conversationManager.breadCrumbMenuModel}" rendered="#{conversationManager.renderBreadCrumb}" />	
		<p:fieldset id="fieldset">
			<input type="hidden" name="_cid_" value="${conversationManager.currentConversation.id}"/>			
			<f:validateBean disabled="true">
				<h:panelGrid columns="2" styleClass="aria-role-presentation">
					<ui:insert name="form" />
				</h:panelGrid>
				<app:saveButton title="${title}" bean="#{bean}"/>
			</f:validateBean>
		</p:fieldset>
		<ui:insert name="tabs" />
	</ui:define>
	<ui:define name="dialogs">
		<ui:insert name="custom-dialogs" />
		<p:confirmDialog widgetVar="askForDeleteDialog" header="${msg.menu_delete}?" message="${msg.dialog_delete_confirm}">
	        <h:panelGrid id="askForDeleteDialogContent" columns="1" cellpadding="4" style="margin:0 auto;">  
	            <h:outputText value="${typeAwarePrinter.print(bean.entity)}" style="font-weight:bold" />  
	        </h:panelGrid>
			<p:commandButton id="askForDeleteDialogYes" action="#{bean.deleteAndClose()}" ajax="false" immediate="true" process="@none" value="${msg.yes}" title="${msg.dialog_delete_confirm} ${msg.yes}" icon="ui-icon-check" />
			<p:commandButton id="askForDeleteDialogNo" value="${msg.no}" title="${msg.dialog_delete_confirm} ${msg.no}" onclick="askForDeleteDialog.hide(); APP.focusTo('form:delete'); return false;" icon="ui-icon-cancel"/>
		</p:confirmDialog>
		<p:confirmDialog widgetVar="askForSaveDialog" header="${msg.menu_save}?" message="${msg.dialog_ask_for_save}">
			<p:commandButton id="askForSaveDialogYes" action="#{bean.saveAndClose()}" ajax="true" process="@form" value="${msg.yes}"
				title="${msg.dialog_ask_for_save} ${msg.yes}"
				onstart="askForSaveDialog.hide()"
				styleClass="aria-save-button"
				update="messages" icon="ui-icon-check" />
			<p:commandButton id="askForSaveDialogNo" action="#{bean.forceClose()}" ajax="false"
				value="${msg.no}"
				title="${msg.dialog_ask_for_save} ${msg.no}"
				icon="ui-icon-cancel" immediate="true" process="@none" />
		</p:confirmDialog>		
	</ui:define>	
</ui:composition >